home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d968.lha / JustLook / Examples / ExampleSources / MoveMouse.jl.c < prev    next >
C/C++ Source or Header  |  1993-12-04  |  2KB  |  77 lines

  1. /* MoveMouse.jl  By Kamran Karimi
  2.  
  3.    Should be linked with JustLook (© Kamran Karimi) routines.
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <intuition/intuition.h>
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11. #include <clib/intuition_protos.h>
  12.  
  13. #include "JustLook.h"
  14.  
  15. struct IntuitionBase *IntuitionBase;
  16.  
  17. #define Write_err printf("err = %08lx\n",err)
  18.  
  19. main()
  20. {
  21.  struct Window *win1,*win2;
  22.  ErrorCode err;
  23.  struct ScrMap SM;
  24.  int count;
  25.  
  26.  IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  27.  if(IntuitionBase == 0) exit(100);
  28.  
  29.  win1 = FindWindow("Workbench",NULL);
  30.  if(win1 > WIN_REPEATED) 
  31.  {
  32.   err = IEDisable(MOUSE|KBD); Write_err;
  33.   printf("Mouse and Keyboard disabled!\n");
  34.   Delay(50);
  35.   InitSM(&SM,win1->WScreen);
  36.   WindowToFront(win1);
  37.   SetDest(&SM,(win1->WScreen)->LeftEdge,(win1->WScreen)->Height / 2);
  38.   MoveMouse(&SM,ABSOLUTE,6);
  39.   Click(&SM,LBUTTON,0,DOWN);
  40.   SetDest(&SM,(win1->WScreen)->Width - 20,(win1->WScreen)->Height - 10);
  41.   MoveMouse(&SM,ABSOLUTE,2);
  42.   Delay(100);
  43.   Click(&SM,LBUTTON,0,UP);
  44.   err = IEEnable(MOUSE|KBD); Write_err;
  45.   printf("Mouse and Keyboard enabled!\n");
  46.  }
  47.  else printf("Trouble finding Workbench window!\n");
  48.  win2 = FindWindow("AmigaShell",NULL);
  49.  if(win2 > WIN_REPEATED)
  50.  {
  51.   WindowToFront(win2);
  52.   Printf("Try to stop me!\n");
  53.   Delay(75);
  54.   InitSM(&SM,win2->WScreen);
  55.   for(count = 1;count < 3; count++)
  56.   {
  57.    SetDest(&SM,0,0);
  58.    MoveMouse(&SM,ABSOLUTE,8);
  59.    SetDest(&SM,(win2->WScreen)->Width - 10,(win2->WScreen)->Height -10);
  60.    MoveMouse(&SM,ABSOLUTE,4);
  61.    SetDest(&SM,(win2->WScreen)->Width - 10,0);
  62.    MoveMouse(&SM,ABSOLUTE,1);
  63.    SetDest(&SM,0,(win2->WScreen)->Height -10);
  64.    MoveMouse(&SM,ABSOLUTE,1);
  65.   }
  66.   printf("That was all!\n");
  67.  }
  68.  else
  69.  {
  70.   if(win2 == WIN_REPEATED) printf("More than 1 AmigaShell window found!\n");
  71.   else printf("AmigaShell window not found!\n");
  72.   printf("Aborted...\n");
  73.  }
  74.  CloseLibrary((struct Library *)IntuitionBase);
  75.  exit(0);
  76. }
  77.